"""闭包函数"""

# def student_grade(name, gender, grade):
#     print(f"霍格沃兹测试学社开学啦！学生的名称是{name}，性别是{gender}，年级是{grade}年级")
#
# student_grade("罗恩", "男", 1)
# student_grade("哈利", "男", 1)
# student_grade("赫敏", "女", 1)

#闭包无法修改外部函数的局部变量
def output_student(grade):
    grade = "2"
    print("外函数的年级为", grade)
    def inner(name, gender):
        grade = "1"
        print("内函数的年级为", grade)
        # print(f"霍格沃兹测试学社开学啦！\学生的名称是{name}，性别是{gender}，年级是{grade}")
    return inner

student = output_student(1)
student("罗恩", "男")
student("哈利", "男")
student("赫敏", "女")

# def output_student(grade):
#     def inner(name, gender):
#         print(f"霍格沃兹测试学社开学啦！\
#         学生的名称是{name}，性别是{gender}，\年级是{grade}")
#
#     return inner
#
# student = output_student(1)
# student("罗恩", "男")
# student("哈利", "男")
# student("赫敏", "女")
